package com.demo.pagers;

import com.demo.Finder;
import org.openqa.selenium.WebElement;

/**
 * Created by Administrator on 2017/7/7.
 */
public class PageLogin {

    private Finder finder;

    public PageLogin(Finder finder){
        this.finder = finder;
    }

    public WebElement getNameET(){
        return finder.findById("com.netease.newsreader.activity:id/ot");
    }

    public WebElement getPwdET(){
        return finder.findById("com.netease.newsreader.activity:id/oz");
    }

    public WebElement getLoginBtn(){
        return finder.findById("com.netease.newsreader.activity:id/p1");
    }

    public void enterName(String name){
        finder.enterText(getNameET(),name);
    }

    public void enterPwd(String pwd){
        finder.enterText(getPwdET(),pwd);
    }

    public void clickLoginBtn(){
        getLoginBtn().click();
    }

    public void clearNameET(){
//        getNameET().clear();
        finder.clear(getNameET());
    }

    public void clearPwdET(){
        finder.clear(getPwdET());
    }

    public void login(String name,String pwd){
        clearNameET();
        enterName(name);
        getPwdET().click();
        enterPwd(pwd);
        clickLoginBtn();
    }
}
